﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
<UserControl
  x:Class="System.Windows.Controls.Samples.AccordionUsage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
  xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
  xmlns:layoutToolkitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit">
  <StackPanel>
    <ContentControl
      Content="Hardcoded items - text"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Hardcoded items - UI Elements"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch">
      <layoutToolkit:AccordionItem>
        <layoutToolkit:AccordionItem.Header>
          <TextBlock
            Text="Image" />
        </layoutToolkit:AccordionItem.Header>
        <layoutToolkit:AccordionItem.Content>
          <Image
            Source="/Silverlight.png" />
        </layoutToolkit:AccordionItem.Content>
      </layoutToolkit:AccordionItem >
      <layoutToolkit:AccordionItem>
        <layoutToolkit:AccordionItem.Header>
          <TextBlock
            Text="Button" />
        </layoutToolkit:AccordionItem.Header>
        <layoutToolkit:AccordionItem.Content>
          <Button
            Content="button as content"
            Margin="10" />
        </layoutToolkit:AccordionItem.Content>
      </layoutToolkit:AccordionItem>
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Orientation left"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      ExpandDirection="Left"
      Height="150">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="One item selected"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me"
        IsSelected="True" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Allowing multiple items"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar"
        IsSelected="True" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Require one open accordion"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="OneOrMore">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Sequential animation"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionSequence="CollapseBeforeExpand">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Generated content"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionGeneratedContent">
      <layoutToolkit:Accordion.ContentTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Key}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ContentTemplate >
      <layoutToolkit:Accordion.ItemTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Value}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ItemTemplate>
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Default header template"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionDefaultHeaderTemplate"
      DisplayMemberPath="Value">
      <layoutToolkit:Accordion.ContentTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Key}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ContentTemplate >
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Using selectionChanged event"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore"
      SelectionChanged="Accordion_SelectionChanged">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar"
        IsSelected="True" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Expanding/collapsing an entire accordion"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionExpandCollapse"
      SelectionMode="ZeroOrMore">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
    </layoutToolkit:Accordion>
    <StackPanel
      Orientation="Horizontal">
      <Button
        Click="ExpandAll_Click"
        Content="Expand Accordion"
        Margin="2" />
      <Button
        Click="CollapseAll_Click"
        Content="Collapse Accordion"
        Margin="2" />
    </StackPanel>
    <ContentControl
      Content="Finding the currently selected clr types"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionCLRTypes"
      SelectionMode="ZeroOrMore"
      SelectedItemsChanged="CLRTypesSelectedItemsChanged">
      <layoutToolkit:Accordion.ContentTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Key}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ContentTemplate>
      <layoutToolkit:Accordion.ItemTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Value}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ItemTemplate>
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Getting an AccordionItem from an Item"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore"
      x:Name="accordionAccordionItem"
      Loaded="SetMouseEvents">
      <layoutToolkit:Accordion.ContentTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Key}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ContentTemplate>
      <layoutToolkit:Accordion.ItemTemplate>
        <DataTemplate>
          <TextBlock
            Text="{Binding Value}" />
        </DataTemplate>
      </layoutToolkit:Accordion.ItemTemplate>
    </layoutToolkit:Accordion>
    <ContentControl
      Content="Restyling and retemplating AccordionItems"
      Style="{StaticResource Header}" />
    <layoutToolkit:Accordion
      HorizontalAlignment="Stretch">
      <layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" />
      <layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" />
      <layoutToolkit:AccordionItem
        Header="mini"
        Content="me" />
      <layoutToolkit:Accordion.ItemContainerStyle>
        <Style
          TargetType="layoutToolkit:AccordionItem">
          <Setter
            Property="Cursor"
            Value="Hand" />
          <Setter
            Property="Template">
            <Setter.Value>
              <ControlTemplate
                TargetType="layoutToolkit:AccordionItem">
                <Grid
                  Background="Transparent">
                  <vsm:VisualStateManager.VisualStateGroups>
                    <!-- CommonState -->
                    <vsm:VisualStateGroup
                      x:Name="CommonStates">
                      <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition
                          GeneratedDuration="0" />
                      </vsm:VisualStateGroup.Transitions>
                      <vsm:VisualState
                        x:Name="Normal" />
                      <vsm:VisualState
                        x:Name="Disabled">
                        <Storyboard>
                          <DoubleAnimation
                            Duration="0"
                            Storyboard.TargetName="DisabledVisualElement"
                            Storyboard.TargetProperty="(UIElement.Opacity)"
                            To="1" />
                        </Storyboard>
                      </vsm:VisualState>
                    </vsm:VisualStateGroup>
                    <!-- FocusStates -->
                    <vsm:VisualStateGroup
                      x:Name="FocusStates">
                      <vsm:VisualState
                        x:Name="Focused">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="FocusVisualElement"
                            Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="Visible" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <!-- Unfocused -->
                      <vsm:VisualState
                        x:Name="Unfocused" />
                    </vsm:VisualStateGroup>
                    <!-- ExpansionStates -->
                    <vsm:VisualStateGroup
                      x:Name="ExpansionStates">
                      <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition
                          GeneratedDuration="0" />
                      </vsm:VisualStateGroup.Transitions>
                      <vsm:VisualState
                        x:Name="Collapsed">
                        <Storyboard>
                          <DoubleAnimationUsingKeyFrames
                            BeginTime="00:00:00"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                            <SplineDoubleKeyFrame
                              KeyTime="00:00:00.3"
                              KeySpline="0.2,0,0,1"
                              Value="0" />
                          </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <vsm:VisualState
                        x:Name="Expanded">
                        <Storyboard>
                          <DoubleAnimationUsingKeyFrames
                            BeginTime="00:00:00"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                            <SplineDoubleKeyFrame
                              KeyTime="00:00:00.3"
                              KeySpline="0.2,0,0,1"
                              Value="1" />
                          </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                    </vsm:VisualStateGroup>
                    <!-- ExpansionStates -->
                    <vsm:VisualStateGroup
                      x:Name="LockedStates">
                      <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition
                          GeneratedDuration="0" />
                      </vsm:VisualStateGroup.Transitions>
                      <vsm:VisualState
                        x:Name="Locked">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="IsEnabled">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="False" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <vsm:VisualState
                        x:Name="Unlocked">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="IsEnabled">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="True" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                    </vsm:VisualStateGroup>
                    <!-- ExpandDirectionStates-->
                    <vsm:VisualStateGroup
                      x:Name="ExpandDirectionStates">
                      <vsm:VisualStateGroup.Transitions>
                        <vsm:VisualTransition
                          GeneratedDuration="0" />
                      </vsm:VisualStateGroup.Transitions>
                      <vsm:VisualState
                        x:Name="ExpandDown">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd1"
                            Storyboard.TargetProperty="Height">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <vsm:VisualState
                        x:Name="ExpandUp">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.Row)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <vsm:VisualState
                        x:Name="ExpandLeft">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.RowSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.RowSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.Column)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                      <vsm:VisualState
                        x:Name="ExpandRight">
                        <Storyboard>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.RowSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.RowSpan)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Column)">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                          <ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd1"
                            Storyboard.TargetProperty="Width">
                            <DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" />
                          </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                      </vsm:VisualState>
                    </vsm:VisualStateGroup>
                  </vsm:VisualStateManager.VisualStateGroups>
                  <Border
                    x:Name="Background"
                    Padding="{TemplateBinding Padding}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
                    <Grid>
                      <Grid.RowDefinitions>
                        <RowDefinition
                          Height="Auto"
                          x:Name="rd0" />
                        <RowDefinition
                          Height="Auto"
                          x:Name="rd1" />
                      </Grid.RowDefinitions>
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition
                          Width="Auto"
                          x:Name="cd0" />
                        <ColumnDefinition
                          Width="Auto"
                          x:Name="cd1" />
                      </Grid.ColumnDefinitions>
                      <layoutToolkitPrimitives:AccordionButton
                        x:Name="ExpanderButton"
                        DataContext="{Binding}"
                        Content="{TemplateBinding Header}"
                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                        IsChecked="{TemplateBinding IsSelected}"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Grid.Row="0"
                        Padding="2"
                        Margin="1"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        FontStyle="{TemplateBinding FontStyle}"
                        FontWeight="{TemplateBinding FontWeight}"
                        Foreground="{TemplateBinding Foreground}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                      <layoutToolkitPrimitives:ExpandableContentControl
                        x:Name="ExpandSite"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Grid.Row="1"
                        Percentage="0"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        RevealMode="{TemplateBinding ExpandDirection}"
                        Padding="2"
                        Margin="1"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        FontStyle="{TemplateBinding FontStyle}"
                        FontWeight="{TemplateBinding FontWeight}"
                        Foreground="{TemplateBinding Foreground}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                  </Border>
                  <Border
                    x:Name="DisabledVisualElement"
                    IsHitTestVisible="false"
                    Opacity="0"
                    Background="#A5FFFFFF"
                    CornerRadius="3" />
                  <Border
                    x:Name="FocusVisualElement"
                    IsHitTestVisible="false"
                    Visibility="Collapsed"
                    BorderThickness="1"
                    CornerRadius="3">
                    <Border.BorderBrush>
                      <LinearGradientBrush
                        EndPoint="0.5,1"
                        StartPoint="0.5,0">
                        <GradientStop
                          Color="#FFA3AEB9" />
                        <GradientStop
                          Color="#FF8399A9"
                          Offset="0.375" />
                        <GradientStop
                          Color="#FF718597"
                          Offset="0.375" />
                        <GradientStop
                          Color="#FF617584"
                          Offset="1" />
                      </LinearGradientBrush>
                    </Border.BorderBrush>
                  </Border>
                  <Rectangle
                    StrokeDashArray="2 1"
                    StrokeThickness="3"
                    Stroke="Black"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch" />
                </Grid>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </layoutToolkit:Accordion.ItemContainerStyle>
    </layoutToolkit:Accordion>
    <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="AccordionUsage.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;
&lt;UserControl
  x:Class="System.Windows.Controls.Samples.AccordionUsage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
  xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
  xmlns:layoutToolkitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit"&gt;
  &lt;StackPanel&gt;
    &lt;ContentControl
      Content="Hardcoded items - text"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Hardcoded items - UI Elements"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"&gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;layoutToolkit:AccordionItem.Header&gt;
          &lt;TextBlock
            Text="Image" /&gt;
        &lt;/layoutToolkit:AccordionItem.Header&gt;
        &lt;layoutToolkit:AccordionItem.Content&gt;
          &lt;Image
            Source="/Silverlight.png" /&gt;
        &lt;/layoutToolkit:AccordionItem.Content&gt;
      &lt;/layoutToolkit:AccordionItem &gt;
      &lt;layoutToolkit:AccordionItem&gt;
        &lt;layoutToolkit:AccordionItem.Header&gt;
          &lt;TextBlock
            Text="Button" /&gt;
        &lt;/layoutToolkit:AccordionItem.Header&gt;
        &lt;layoutToolkit:AccordionItem.Content&gt;
          &lt;Button
            Content="button as content"
            Margin="10" /&gt;
        &lt;/layoutToolkit:AccordionItem.Content&gt;
      &lt;/layoutToolkit:AccordionItem&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Orientation left"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      ExpandDirection="Left"
      Height="150"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="One item selected"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me"
        IsSelected="True" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Allowing multiple items"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar"
        IsSelected="True" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Require one open accordion"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="OneOrMore"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Sequential animation"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionSequence="CollapseBeforeExpand"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Generated content"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionGeneratedContent"&gt;
      &lt;layoutToolkit:Accordion.ContentTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Key}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ContentTemplate &gt;
      &lt;layoutToolkit:Accordion.ItemTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Value}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ItemTemplate&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Default header template"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionDefaultHeaderTemplate"
      DisplayMemberPath="Value"&gt;
      &lt;layoutToolkit:Accordion.ContentTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Key}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ContentTemplate &gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Using selectionChanged event"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore"
      SelectionChanged="Accordion_SelectionChanged"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World"
        IsSelected="True" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar"
        IsSelected="True" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Expanding/collapsing an entire accordion"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionExpandCollapse"
      SelectionMode="ZeroOrMore"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;StackPanel
      Orientation="Horizontal"&gt;
      &lt;Button
        Click="ExpandAll_Click"
        Content="Expand Accordion"
        Margin="2" /&gt;
      &lt;Button
        Click="CollapseAll_Click"
        Content="Collapse Accordion"
        Margin="2" /&gt;
    &lt;/StackPanel&gt;
    &lt;ContentControl
      Content="Finding the currently selected clr types"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      x:Name="accordionCLRTypes"
      SelectionMode="ZeroOrMore"
      SelectedItemsChanged="CLRTypesSelectedItemsChanged"&gt;
      &lt;layoutToolkit:Accordion.ContentTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Key}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ContentTemplate&gt;
      &lt;layoutToolkit:Accordion.ItemTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Value}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ItemTemplate&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Getting an AccordionItem from an Item"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"
      SelectionMode="ZeroOrMore"
      x:Name="accordionAccordionItem"
      Loaded="SetMouseEvents"&gt;
      &lt;layoutToolkit:Accordion.ContentTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Key}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ContentTemplate&gt;
      &lt;layoutToolkit:Accordion.ItemTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock
            Text="{Binding Value}" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/layoutToolkit:Accordion.ItemTemplate&gt;
    &lt;/layoutToolkit:Accordion&gt;
    &lt;ContentControl
      Content="Restyling and retemplating AccordionItems"
      Style="{StaticResource Header}" /&gt;
    &lt;layoutToolkit:Accordion
      HorizontalAlignment="Stretch"&gt;
      &lt;layoutToolkit:AccordionItem
        Header="Hello"
        Content="World" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="foo"
        Content="bar" /&gt;
      &lt;layoutToolkit:AccordionItem
        Header="mini"
        Content="me" /&gt;
      &lt;layoutToolkit:Accordion.ItemContainerStyle&gt;
        &lt;Style
          TargetType="layoutToolkit:AccordionItem"&gt;
          &lt;Setter
            Property="Cursor"
            Value="Hand" /&gt;
          &lt;Setter
            Property="Template"&gt;
            &lt;Setter.Value&gt;
              &lt;ControlTemplate
                TargetType="layoutToolkit:AccordionItem"&gt;
                &lt;Grid
                  Background="Transparent"&gt;
                  &lt;vsm:VisualStateManager.VisualStateGroups&gt;
                    &lt;!-- CommonState --&gt;
                    &lt;vsm:VisualStateGroup
                      x:Name="CommonStates"&gt;
                      &lt;vsm:VisualStateGroup.Transitions&gt;
                        &lt;vsm:VisualTransition
                          GeneratedDuration="0" /&gt;
                      &lt;/vsm:VisualStateGroup.Transitions&gt;
                      &lt;vsm:VisualState
                        x:Name="Normal" /&gt;
                      &lt;vsm:VisualState
                        x:Name="Disabled"&gt;
                        &lt;Storyboard&gt;
                          &lt;DoubleAnimation
                            Duration="0"
                            Storyboard.TargetName="DisabledVisualElement"
                            Storyboard.TargetProperty="(UIElement.Opacity)"
                            To="1" /&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                    &lt;/vsm:VisualStateGroup&gt;
                    &lt;!-- FocusStates --&gt;
                    &lt;vsm:VisualStateGroup
                      x:Name="FocusStates"&gt;
                      &lt;vsm:VisualState
                        x:Name="Focused"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="FocusVisualElement"
                            Storyboard.TargetProperty="Visibility"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="Visible" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;!-- Unfocused --&gt;
                      &lt;vsm:VisualState
                        x:Name="Unfocused" /&gt;
                    &lt;/vsm:VisualStateGroup&gt;
                    &lt;!-- ExpansionStates --&gt;
                    &lt;vsm:VisualStateGroup
                      x:Name="ExpansionStates"&gt;
                      &lt;vsm:VisualStateGroup.Transitions&gt;
                        &lt;vsm:VisualTransition
                          GeneratedDuration="0" /&gt;
                      &lt;/vsm:VisualStateGroup.Transitions&gt;
                      &lt;vsm:VisualState
                        x:Name="Collapsed"&gt;
                        &lt;Storyboard&gt;
                          &lt;DoubleAnimationUsingKeyFrames
                            BeginTime="00:00:00"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(ExpandableContentControl.Percentage)"&gt;
                            &lt;SplineDoubleKeyFrame
                              KeyTime="00:00:00.3"
                              KeySpline="0.2,0,0,1"
                              Value="0" /&gt;
                          &lt;/DoubleAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;vsm:VisualState
                        x:Name="Expanded"&gt;
                        &lt;Storyboard&gt;
                          &lt;DoubleAnimationUsingKeyFrames
                            BeginTime="00:00:00"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(ExpandableContentControl.Percentage)"&gt;
                            &lt;SplineDoubleKeyFrame
                              KeyTime="00:00:00.3"
                              KeySpline="0.2,0,0,1"
                              Value="1" /&gt;
                          &lt;/DoubleAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                    &lt;/vsm:VisualStateGroup&gt;
                    &lt;!-- ExpansionStates --&gt;
                    &lt;vsm:VisualStateGroup
                      x:Name="LockedStates"&gt;
                      &lt;vsm:VisualStateGroup.Transitions&gt;
                        &lt;vsm:VisualTransition
                          GeneratedDuration="0" /&gt;
                      &lt;/vsm:VisualStateGroup.Transitions&gt;
                      &lt;vsm:VisualState
                        x:Name="Locked"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="IsEnabled"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="False" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;vsm:VisualState
                        x:Name="Unlocked"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="IsEnabled"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="True" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                    &lt;/vsm:VisualStateGroup&gt;
                    &lt;!-- ExpandDirectionStates--&gt;
                    &lt;vsm:VisualStateGroup
                      x:Name="ExpandDirectionStates"&gt;
                      &lt;vsm:VisualStateGroup.Transitions&gt;
                        &lt;vsm:VisualTransition
                          GeneratedDuration="0" /&gt;
                      &lt;/vsm:VisualStateGroup.Transitions&gt;
                      &lt;vsm:VisualState
                        x:Name="ExpandDown"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd1"
                            Storyboard.TargetProperty="Height"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;vsm:VisualState
                        x:Name="ExpandUp"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.Row)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;vsm:VisualState
                        x:Name="ExpandLeft"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.RowSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.RowSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.Column)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd0"
                            Storyboard.TargetProperty="Width"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                      &lt;vsm:VisualState
                        x:Name="ExpandRight"&gt;
                        &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.ColumnSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpanderButton"
                            Storyboard.TargetProperty="(Grid.RowSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.RowSpan)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="2" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Row)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="0" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="ExpandSite"
                            Storyboard.TargetProperty="(Grid.Column)"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="1" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="rd0"
                            Storyboard.TargetProperty="Height"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames
                            Duration="0"
                            Storyboard.TargetName="cd1"
                            Storyboard.TargetProperty="Width"&gt;
                            &lt;DiscreteObjectKeyFrame
                              KeyTime="0"
                              Value="*" /&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                        &lt;/Storyboard&gt;
                      &lt;/vsm:VisualState&gt;
                    &lt;/vsm:VisualStateGroup&gt;
                  &lt;/vsm:VisualStateManager.VisualStateGroups&gt;
                  &lt;Border
                    x:Name="Background"
                    Padding="{TemplateBinding Padding}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"&gt;
                    &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                        &lt;RowDefinition
                          Height="Auto"
                          x:Name="rd0" /&gt;
                        &lt;RowDefinition
                          Height="Auto"
                          x:Name="rd1" /&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                        &lt;ColumnDefinition
                          Width="Auto"
                          x:Name="cd0" /&gt;
                        &lt;ColumnDefinition
                          Width="Auto"
                          x:Name="cd1" /&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;layoutToolkitPrimitives:AccordionButton
                        x:Name="ExpanderButton"
                        DataContext="{Binding}"
                        Content="{TemplateBinding Header}"
                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                        IsChecked="{TemplateBinding IsSelected}"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Grid.Row="0"
                        Padding="2"
                        Margin="1"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        FontStyle="{TemplateBinding FontStyle}"
                        FontWeight="{TemplateBinding FontWeight}"
                        Foreground="{TemplateBinding Foreground}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /&gt;
                      &lt;layoutToolkitPrimitives:ExpandableContentControl
                        x:Name="ExpandSite"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Grid.Row="1"
                        Percentage="0"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        RevealMode="{TemplateBinding ExpandDirection}"
                        Padding="2"
                        Margin="1"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStretch="{TemplateBinding FontStretch}"
                        FontStyle="{TemplateBinding FontStyle}"
                        FontWeight="{TemplateBinding FontWeight}"
                        Foreground="{TemplateBinding Foreground}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /&gt;
                    &lt;/Grid&gt;
                  &lt;/Border&gt;
                  &lt;Border
                    x:Name="DisabledVisualElement"
                    IsHitTestVisible="false"
                    Opacity="0"
                    Background="#A5FFFFFF"
                    CornerRadius="3" /&gt;
                  &lt;Border
                    x:Name="FocusVisualElement"
                    IsHitTestVisible="false"
                    Visibility="Collapsed"
                    BorderThickness="1"
                    CornerRadius="3"&gt;
                    &lt;Border.BorderBrush&gt;
                      &lt;LinearGradientBrush
                        EndPoint="0.5,1"
                        StartPoint="0.5,0"&gt;
                        &lt;GradientStop
                          Color="#FFA3AEB9" /&gt;
                        &lt;GradientStop
                          Color="#FF8399A9"
                          Offset="0.375" /&gt;
                        &lt;GradientStop
                          Color="#FF718597"
                          Offset="0.375" /&gt;
                        &lt;GradientStop
                          Color="#FF617584"
                          Offset="1" /&gt;
                      &lt;/LinearGradientBrush&gt;
                    &lt;/Border.BorderBrush&gt;
                  &lt;/Border&gt;
                  &lt;Rectangle
                    StrokeDashArray="2 1"
                    StrokeThickness="3"
                    Stroke="Black"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch" /&gt;
                &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
            &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
        &lt;/Style&gt;
      &lt;/layoutToolkit:Accordion.ItemContainerStyle&gt;
    &lt;/layoutToolkit:Accordion&gt;
  &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="AccordionUsage.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Globalization;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample page for Accordion, showing usages.
    /// &lt;/summary&gt;
    [Sample("Accordion Usage samples", DifficultyLevel.Basic)]
    [Category("Accordion")]
    public partial class AccordionUsage : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref="AccordionUsage"/&gt; class.
        /// &lt;/summary&gt;
        public AccordionUsage()
        {
            InitializeComponent();

            KeyValuePair&lt;string, string&gt;[] data = new KeyValuePair&lt;string, string&gt;[]
            {
                new KeyValuePair&lt;string, string&gt;("Hello", "World"),
                new KeyValuePair&lt;string, string&gt;("foo", "bar"),
                new KeyValuePair&lt;string, string&gt;("Silverlight", "Toolkit"),
            };

            // initialize accordions
            accordionGeneratedContent.ItemsSource = data;
            accordionDefaultHeaderTemplate.ItemsSource = data;
            accordionCLRTypes.ItemsSource = data;
            accordionAccordionItem.ItemsSource = data;
        }

        /// &lt;summary&gt;
        /// Handles the SelectionChanged event of the accordion control.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.Controls.SelectionChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Hooked up in Xaml")]
        private void Accordion_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (AccordionItem SelectedAccordionItem in e.AddedItems)
            {
                Debug.WriteLine(string.Format(
                    CultureInfo.InvariantCulture, 
                    "AccordionItem {0} has been selected.",
                    SelectedAccordionItem.Header));
            }
        }
        
        /// &lt;summary&gt;
        /// Handles the Click event of the btnExpandAll control.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Hooked up in Xaml")]
        private void ExpandAll_Click(object sender, RoutedEventArgs e)
        {
            accordionExpandCollapse.SelectAll();
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the btnCollapseAll control.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Hooked up in Xaml")]
        private void CollapseAll_Click(object sender, RoutedEventArgs e)
        {
            accordionExpandCollapse.UnselectAll();
        }

        /// &lt;summary&gt;
        /// Handles the SelectionChanged event for the CLRTypes sample.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.Controls.SelectionChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Hooked up in Xaml")]
        private void CLRTypesSelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
                    foreach (
                        KeyValuePair&lt;string, string&gt; keyValuePair in
                            accordionCLRTypes.SelectedItems)
                    {
                        Debug.WriteLine("Interesting, people like seeing details on " +
                                        keyValuePair.Key);
                    }
        }

        /// &lt;summary&gt;
        /// Hooks up events for the MouseOver sample.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The sender.&lt;/param&gt;
        /// &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
        [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "keyValuePair", Justification = "TODO: THIS WILL BE REMOVED ONCE ITEM CONTAINER GENERATOR STUFF IS TAKEN CARE OF. TODO.")]
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Hooked up in Xaml")]
        private void SetMouseEvents(object sender, RoutedEventArgs e)
        {
            foreach (KeyValuePair&lt;string, string&gt; keyValuePair in accordionAccordionItem.Items)
            {
                AccordionItem container = accordionAccordionItem.ItemContainerGenerator.ContainerFromItem(keyValuePair) as AccordionItem;
                if (container != null)
                {
                    container.MouseEnter += (s, args) =&gt;
                    {
                        if (!container.IsLocked)
                        {
                            container.IsSelected = true;
                        }
                    };

                    container.MouseLeave += (s, args) =&gt;
                    {
                        if (!container.IsLocked)
                        {
                            container.IsSelected = false;
                        }
                    };
                }
            }
        }
    }
}
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="AccordionUsage.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to &lt;###LICENSE_NAME###&gt;.
' Please see &lt;###LICENSE_LINK###&gt; for details.
' All other rights reserved.

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports System.Globalization

''' &lt;summary&gt;
''' Sample page for Accordion, showing usages.
''' &lt;/summary&gt;
&lt;Sample("Accordion Usage samples", DifficultyLevel.Basic), Category("Accordion")&gt; _
Partial Public Class AccordionUsage
    Inherits UserControl
    ''' &lt;summary&gt;
    ''' Initializes a new instance of the &lt;see cref="AccordionUsage"/&gt; class.
    ''' &lt;/summary&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification:="InitializeComponent Required by Visual Studio.")&gt; _
    Public Sub New()
        InitializeComponent()

        Dim data() As KeyValuePair(Of String, String) = {New KeyValuePair(Of String, String)("Hello", "World"), New KeyValuePair(Of String, String)("foo", "bar"), New KeyValuePair(Of String, String)("Silverlight", "Toolkit")}

        ' initialize accordions
        accordionGeneratedContent.ItemsSource = data
        accordionDefaultHeaderTemplate.ItemsSource = data
        accordionCLRTypes.ItemsSource = data
        accordionAccordionItem.ItemsSource = data
    End Sub

    ''' &lt;summary&gt;
    ''' Handles the SelectionChanged event of the accordion control.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.Controls.SelectionChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Hooked up in Xaml")&gt; _
    Private Sub Accordion_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        For Each SelectedAccordionItem As AccordionItem In e.AddedItems
            Debug.WriteLine(String.Format(CultureInfo.InvariantCulture, "AccordionItem {0} has been selected.", SelectedAccordionItem.Header))
        Next SelectedAccordionItem
    End Sub

    ''' &lt;summary&gt;
    ''' Handles the Click event of the btnExpandAll control.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Hooked up in Xaml")&gt; _
    Private Sub ExpandAll_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        accordionExpandCollapse.SelectAll()
    End Sub

    ''' &lt;summary&gt;
    ''' Handles the Click event of the btnCollapseAll control.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Hooked up in Xaml")&gt; _
    Private Sub CollapseAll_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        accordionExpandCollapse.UnselectAll()
    End Sub

    ''' &lt;summary&gt;
    ''' Handles the SelectionChanged event for the CLRTypes sample.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.Controls.SelectionChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Hooked up in Xaml")&gt; _
    Private Sub CLRTypesSelectedItemsChanged(ByVal sender As Object, ByVal e As NotifyCollectionChangedEventArgs)
        For Each keyValuePair As KeyValuePair(Of String, String) In accordionCLRTypes.SelectedItems
            Debug.WriteLine("Interesting, people like seeing details on " &amp; keyValuePair.Key)
        Next keyValuePair
    End Sub

    ''' &lt;summary&gt;
    ''' Hooks up events for the MouseOver sample.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.RoutedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification:="Hooked up in Xaml")&gt; _
    Private Sub SetMouseEvents(ByVal sender As Object, ByVal e As RoutedEventArgs)
        For Each keyValuePair As KeyValuePair(Of String, String) In accordionAccordionItem.Items
            Dim container As AccordionItem = CType(accordionAccordionItem.ItemContainerGenerator.ContainerFromItem(keyValuePair), AccordionItem)
            AddHandler container.MouseEnter, AddressOf Mouse_Enter
            AddHandler container.MouseLeave, AddressOf Mouse_Leave
        Next keyValuePair
    End Sub

    ''' &lt;summary&gt;
    ''' Handle the MouseEnter event.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.Input.MouseEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    Private Sub Mouse_Enter(ByVal sender As Object, ByVal e As MouseEventArgs)
        Dim container As AccordionItem = CType(sender, AccordionItem)
        If (Not container.IsLocked) Then
            container.IsSelected = True
        End If
    End Sub

    ''' &lt;summary&gt;
    ''' Handle the MouseLeave event.
    ''' &lt;/summary&gt;
    ''' &lt;param name="sender"&gt;The sender.&lt;/param&gt;
    ''' &lt;param name="e"&gt;The &lt;see cref="System.Windows.Input.MouseEventArgs"/&gt; instance containing the event data.&lt;/param&gt;
    Private Sub Mouse_Leave(ByVal sender As Object, ByVal e As MouseEventArgs)
        Dim container As AccordionItem = CType(sender, AccordionItem)
        If (Not container.IsLocked) Then
            container.IsSelected = False
        End If
    End Sub
End Class</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
  </StackPanel>
</UserControl>
